﻿//-----------------------------------------------------------------------
// <copyright file="Copyright.cs" author="Michael Herndon">
//     Copyright (c) Michael Herndon.  All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Amplify.Twitter
{
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Net;
	using System.Text;
	using System.Security;

	/// <summary>
	/// A factory class that is designed for an application that only has 
	/// one user logged in at a time that creates a proxy to each specific part
	/// of the twitter api.
	/// </summary>
	public class Twitter
	{

		private static string Password { get; set; }
		private static string Username { get; set; }
		private static IWebProxy Proxy { get; set; }

		/// <summary>
		/// Sets the <see cref="System.Net.NetworkCredential"/> object with the supplied username and password. 
		/// </summary>
		/// <param name="username">The username (screenname) for twitter.</param>
		/// <param name="password">The password for twitter.</param>
		/// <example>
		///		<code class="code csharp">
		///			Twitter.SetCredentials("username", "dwerE3%$");
		///			UserClient Client = Twitter.CreateUserClient();
		///			List&lt;User&gt; friends = service.GetFriends();
		///		</code>
		/// </example>
		public static void SetCredentials(string username, string password) 
		{
			Username = username;
			Password = password;
		}

		/// <summary>
		/// Sets the <see cref="System.Net.NetworkCredential"/> object with the supplied username and password. 
		/// </summary>
		/// <param name="username">The username (screenname) for twitter.</param>
		/// <param name="password">The password for twitter.</param>
		/// <param name="proxy">The <see cref="System.Net.IWebProxy"/> object that will be applied to the <see cref="System.Net.HttpWebRequest" /> object. </param>
		/// <example>
		///		<code class="code csharp">
		///			Twitter.SetCredentials("username", "dwerE3%$", new WebProxy("godaddy", 870));
		///			UserClient Client = Twitter.CreateUserClient();
		///			List&lt;User&gt; friends = service.GetFriends();
		///		</code>
		/// </example>
		public static void SetCredentials(string username, string password, IWebProxy proxy)
		{
			SetCredentials(username, password);
			Proxy = proxy;
		}

		/// <summary>
		/// Creates a <see cref="Amplify.Twitter.BlockClient"/> used to block users.
		/// </summary>
		/// <returns>returns a <see cref="Amplify.Twitter.BlockClient"/> object. </returns>
		/// <example>
		///		<code class="code csharp">
		///			Twitter.SetCredentials("username", "dwerE3%$");
		///			BlockClient Client = Twitter.CreateBlockClient();
		///			User blockedUser = service.Create("username");
		///		</code>
		/// </example>
		public static BlockClient CreateBlockClient()
		{
			return new BlockClient(Username, Password);
		}

		/// <summary>
		/// Creates a <see cref="Amplify.Twitter.AccountClient"/> used to administer the current user.
		/// </summary>
		/// <returns>returns a <see cref="Amplify.Twitter.AccountClient"/> object.</returns>
		/// <example>
		///		<code class="code csharp">
		///			Twitter.SetCredentials("username", "dwerE3%$");
		///			AccountClient Client = Twitter.CreateAccountClient();
		///			bool verified = service.Verify();
		///		</code>
		/// </example>
		public static AccountClient CreateAccountClient()
		{
			return new AccountClient(Username, Password);
		}

		/// <summary>
		/// Creates a <see cref="Amplify.Twitter.DirectMessageClient"/> used manage direct messages.
		/// </summary>
		/// <returns>returns a <see cref="Amplify.Twitter.DirectMessageClient"/> object. </returns>
		/// <example>
		///		<code class="code csharp">
		///			Twitter.SetCredentials("username", "dwerE3%$");
		///			DirectMessageClient Client = Twitter.CreateDirectMessageClient();
		///			List&lt;DirectMessage&gt; messages = service.GetList();
		///		</code>
		/// </example>
		public static DirectMessageClient CreateDirectMessageClient()
		{
			return new DirectMessageClient(Username, Password);
		}

		/// <summary>
		/// Creates a <see cref="Amplify.Twitter.FavoriteClient"/> used to manage a users favorite tweets.
		/// </summary>
		/// <returns>returns a <see cref="Amplify.Twitter.FavoriteClient"/> object. </returns>
		/// <example>
		///		<code class="code csharp">
		///			Twitter.SetCredentials("username", "dwerE3%$");
		///			FavoritesClient Client = Twitter.CreateFavoritesClient();
		///			List&lt;Status&gt; tweets = service.GetList();
		///		</code>
		/// </example>
		public static FavoriteClient CreateFavoriteClient()
		{
			return new FavoriteClient(Username, Password);
		}

		/// <summary>
		/// Creates a <see cref="Amplify.Twitter.FriendshipClient"/> used to manage a users various friendships.
		/// </summary>
		/// <returns>returns a <see cref="Amplify.Twitter.FriendshipClient"/> object. </returns>
		/// <example>
		///		<code class="code csharp">
		///			Twitter.SetCredentials("username", "dwerE3%$");
		///			FriendshipClient Client = Twitter.CreateFriendshipClient();
		///			User friends = service.Create("vachica");
		///		</code>
		/// </example>
		public static FriendshipClient CreateFriendshipClient()
		{	
			return new FriendshipClient(Username, Password);
		}

		/// <summary>
		/// Creates a <see cref="HelpClient"/> used to call help utitilities.
		/// </summary>
		/// <returns>returns a <see cref="Amplify.Twitter.HelpClient"/></returns>
		/// <example>
		///		<code class="code csharp">
		///			Twitter.SetCredentials("username", "dwerE3%$");
		///			HelpClient Client = Twitter.CreateHelpClient();
		///			bool test = service.Test();
		///		</code>
		/// </example>
		public static HelpClient CreateHelpClient()
		{
			return new HelpClient(Username, Password);
		}

		/// <summary>
		/// Creates a <see cref="Amplify.Twitter.NotificationClient"/> used to manage notifications.
		/// </summary>
		/// <returns>returns a <see cref="Amplify.Twitter.NotificationClient"/> object. </returns>
		/// <example>
		///		<code class="code csharp">
		///			Twitter.SetCredentials("username", "dwerE3%$");
		///			NotificationsClient Client = Twitter.CreateNotificationsClient();
		///			User friends = service.Create("vagirl");
		///		</code>
		/// </example>
		public static NotificationClient CreateNotificationClient()
		{
			return new NotificationClient(Username, Password);
		}

		/// <summary>
		/// Creates a <see cref="Amplify.Twitter.StatusClient"/> used to obtain, create, and destroy statuses (tweets).
		/// </summary>
		/// <returns>returns a <see cref="Amplify.Twitter.StatusClient"/> object. </returns>
		/// <example>
		///		<code class="code csharp">
		///			Twitter.SetCredentials("username", "dwerE3%$");
		///			StatusClient Client = Twitter.CreateStatusClient();
		///			List&lt;Status&gt; tweets = service.GetUserTimeline();
		///		</code>
		/// </example>
		public static StatusClient CreateStatusClient()
		{
			return new StatusClient(Username, Password);
		}

		/// <summary>
		/// Creates a <see cref="Amplify.Twitter.UserClient"/> used to obtain, create, and destory users/friends
		/// </summary>
		/// <returns>returns a <see cref="Amplify.Twitter.UserClient"/> object.</returns>
		/// <example>
		///		<code class="code csharp">
		///			Twitter.SetCredentials("username", "dwerE3%$");
		///			UserClient Client = Twitter.CreateUserClient();
		///			List&lt;User&gt; friends = service.GetFriends();
		///		</code>
		/// </example>
		public static UserClient CreateUserClient()
		{
			return new UserClient(Username, Password);
		}

	}
}
